package leetcode.treeCode.week3.leetcode_112;

class Solution {
    public boolean hasPathSum(TreeNode root, int targetSum) {
        return dfs (root , targetSum);
    }
    public boolean dfs (TreeNode node , int targetSum){
        if (node == null ) return false;
        if (node.left == null && node.right == null){
            return targetSum == node.val;
        }
        return dfs (node.left , targetSum - node.val) || dfs (node.right , targetSum - node.val);
    }
}